package com.mybatis.demo.service.impl;

import com.mybatis.demo.dao.IStudentMapper;
import com.mybatis.demo.domain.Student;
import com.mybatis.demo.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {
   @Autowired
    private IStudentMapper iStudentMapper;

    @Override
    public List<Student> searchAll(Long page,Long size,String studentName) {
        return iStudentMapper.searchAll((page - 1)*size,size,studentName);
    }

    @Override
    public int count(String studentName) {
        return iStudentMapper.count(studentName);
    }

    @Override
    public int deleteStu(Long id) {
        return iStudentMapper.deleteById(id);
    }

    @Override
    public int addStu(Student student) {
        return iStudentMapper.insert(student);
    }

    @Override
    public int updateStu(Student student) {
        System.out.println(student);
        return iStudentMapper.update(student);
    }
}
